package com.cmf.myproject.controller.system.menu;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cmf.myproject.dal.mybatis.model.SysMenu;
import com.cmf.myproject.service.system.menu.MenuService;
import com.cmf.myproject.service.system.menu.dto.MenuNodeRsp;
import com.cmf.myproject.service.system.menu.dto.TreeGridDto;
import com.system.core.controller.ControllerBase;
import com.system.core.results.ResultBase;

import lombok.extern.slf4j.Slf4j;
@Controller
@RequestMapping(value = "boss")
@Slf4j
public class MenuController extends ControllerBase {
	
	@Autowired
	private MenuService menuService;

	@RequiresPermissions("menu_topage")
	@RequestMapping("system-menu-page")
	public String menuPage() {
		return "/system/menu/menu";
	}

	@RequestMapping("get-tree-grid")
	@ResponseBody
	public TreeGridDto getTreeGrid() {
		return menuService.getTreeGrid();
	}
	
	@RequestMapping("add-tree-node")
	@ResponseBody
	public MenuNodeRsp addTreeNode(SysMenu sysMenu) {
		return menuService.addMenuNode(sysMenu);
	}
	
	@RequestMapping("edit-tree-node")
	@ResponseBody
	public MenuNodeRsp editTreeNode(SysMenu sysMenu) {
		return menuService.editMenuNode(sysMenu);
	}
	
	@RequestMapping("del-tree-node")
	@ResponseBody
	public ResultBase delTreeNode(Long menuId) {
		return menuService.delMenuNode(menuId);
	}
}
